package com.yiwei.zhh.api.requestInfo;

import com.yiwei.zhh.api.Api;
import com.yiwei.zhh.api.bean.BannerBean;
import com.yiwei.zhh.api.callback.BannerContract;
import com.yiwei.zhh.util.Network;
import com.yiwei.zhh.util.RxLifeUtil;
import com.yiwei.zhh.util.ToastUtil;

/**
 * Created by Administrator on 2017/5/14.
 */

public class BannerRequest extends BaseRequest<BannerContract.View> implements BannerContract.Presenter<BannerContract.View> {

    public static BannerRequest create() {
        return new BannerRequest();
    }
    public static final String TYPE_DEAL = "deal";
    public static final String TYPE_TOP = "top";



    @Override
    public void getBanner(String group_name) {
        if (!Network.checkNetwork(BaseContext)) {
            ToastUtil.makeText(BaseContext, networkFail).show();
            return;
        }
        mView.onRequestStart();
        BannerBean bean = new BannerBean();
        bean.group_name = group_name;

        Api.api_service.getBannerInfo(bean).compose(RxLifeUtil.checkOn(BaseContext)).
                doFinally(() -> {
                    try {
                        mView.complete();
                    } catch (NullPointerException e) {

                    }
                }).
                subscribe(result -> {
                    mView.getBannerSuccess(result);
                });
    }
}
